package com.larry.spark.rdd.transform

import org.apache.spark.{SparkConf, SparkContext}

object RDD_Oper_FlatMap_1 {

  def main(args: Array[String]): Unit = {
    //TODO  使用spark

    val conf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    val sc = new SparkContext(conf)

    val rdd = sc.makeRDD(
      List(List(1,2),3,List(4,5))
    )

    //扁平化  模式匹配
    val rdd1 = rdd.flatMap {
      case list : List[_] => list
      case other => List(other)
    }

    rdd1.collect().foreach(println)

    sc.stop()
  }
}
